﻿using UnityEngine;
using System.Collections;
using UnityEditor;
using System;

namespace Hont.HyperWigglePackage.Editor
{
    public class AutoStable : IHyperWigglePlugin
    {
        public GUIContent Name { get { return new GUIContent("AutoStable"); } }


        public void Execute(HyperWiggleEditorCore core)
        {
            HyperWiggleUtil.StableOffset(core.FrameData);

            var invalidPosition = Vector3.zero;
            var invalidRotation = Vector3.zero;
            HyperWiggleUtil.IsInvalidWiggle(core.FrameData, out invalidPosition, out invalidRotation);

            Debug.Log("Invalid Position: " + invalidPosition.ToString("F10") + " Invalid Rotation: " + invalidRotation.ToString("F10"));

            core.UpdatePreview();
            core.UpdateTimeline();
        }
    }
}